package ru.jetsoft.reg112.desktop.data;

public enum ValueType {

    DOUBLE(10),
    INTEGER(30),
    STRING(50),
    TIMESTAMP(60),
    DATE(70),
    BOOLEAN(80),
    GROUP(90),
    SYSTEM112_ARCH_DIC(100, true),
    READINESS_SYSTEM112_DIC(120, true),
    READINESS_COMPONENT_DIC(130, true),
    COMPONENTS_DIC(140, true),
    ADDRESS(150),
    DATA_SUPPLY_HEADER(160, true),
    LANGUAGE_DIC(170, true),
    SPECIALIST_STATE_DIC(180, true),
    SPECIALIST_LOCATION_DIC(190, true),
    DOCUMENT_TYPE_DIC(200, true),
    EDDS_BASE_DIC(210, true),
    EDDS_DISPOSITION_DIC(220, true),
    DDS_TYPE_DIC(230, true),
    COUNTRY_LEVEL_DIC(240, true),
    CONTROLLED_OBJECT_DIC(250, true),
    TERRITORY_TYPE_DIC(260, true),
    EMERGENCY_SERVICE_DIC(270, true);

    private final int code;
    private final boolean dic;

    private ValueType(int code) {
        this(code, false);
    }

    private ValueType(int code, boolean dic) {
        this.code = code;
        this.dic = dic;
    }

    public int getCode() {
        return code;
    }

    public boolean isDic() {
        return dic;
    }

    public static ValueType getType(int code) {
        for(ValueType type : values()) {
            if(type.getCode() == code) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown type code " + code);
    }
}
